<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>vue test</title>
  <script src="https://cdn.bootcss.com/vue/2.5.16/vue.min.js"></script>
</head>
<body>
  <div id="app">
    <input id="myInput" ref="input"/>
    <button @click="focusInput">点击聚焦</button>
  </div>
  <script type="text/javascript">
  let vm = new Vue({
    el: "#app",
    data: {
      arr: [{name: "sfasf", sex:"gender"}]
    },
    created() {
      // this.$nextTick(function() {
      //   console.log(this.$refs, "refs")
      //   this.$refs.input.focus()
      // })
    },
    methods: {
      focusInput() {
        // this.$refs.input.focus()
        document.getElementById("myInput").focus()
      }
    }
  })
  </script>
</body>
</html>